<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('借阅列表')" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="role-form">
					<div class="select-list">
						<ul>
							<li>
								借阅人：<input type="text" name="user_name"/>
							</li>
							<li>
								图书名称：<input type="text" name="name"/>
							</li>
							<li>
								归还类型：
								<select name="backType">
									<option value="">--请选择归还类型--</option>
									<option value="0">正常还书</option>
									<option value="1">破损还书</option>
									<option value="2">丢失图书</option>
									<option value="3">延迟还书</option>
									<option value="4">尚未归还</option>
								</select>
							</li>
							<li class="select-time">
								<label>图书类型：</label>
								<select name="typeId">
									<option value="">--请选择图书类型--</option>
									<option   th:each="libraryType:${libraryTypes}" th:value="${libraryType.typeId}" th:text="${libraryType.tyname}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	<th:block th:include="include :: footer" />
	<script th:inline="javascript">
		var prefix = ctx + "admin/library/borrow/person";


		$(function() {
		    var options = {
		        url: prefix + "/list",
		        sortName: "a.lend_date",
		        modalName: "图书借阅",
				showPageGo: true,
		        columns: [{
		            checkbox: true
		        },
				{
						field: 'borrowId',
						title: '借阅序号',
						visible:false
					},
		        {
		            field: 'libraryBook.name',
		            title: '图书名称',
					formatter: function(value, row, index) {
						var name = row.libraryBook.name;
						return '<a href="javascript:void(0)" style="color:#00b7ee">'+name+'</a>'
					}
		        },
				{
						field: 'libraryType.tyname',
						title: '图书类型'
				},
		        {
		            field: 'user.userName',
		            title: '借阅人',
					formatter: function(value, row, index) {
		            	var username = row.user.userName;
		            	return '<a href="javascript:void(0)" style="color:#00b7ee">'+username+'</a>'
					}
		        },
		        {
		            field: 'dept.deptName',
		            title: '班级'
		        },
				{
						field: 'lendDate',
						title: '借阅时间',
						sortable: true,
						sortName: 'a.lend_date'
				},
				{
						field: 'backDate',
						title: '还书时间',
						sortable: true,
						sortName: 'a.back_date'
				},
				{
						field: 'backType',
						title: '还书状态',
						formatter: function(value, row, index) {
							var backtype = row.backType
							if (backtype===0){
								return '<a class=\"btn btn-primary btn-xs btn-rounded\" href=\"#\">正常还书</a>';
							}else if (backtype===1){
								return '<a class=\"btn btn-success btn-xs btn-rounded\" href=\"#\">破损还书</a>';
							}else if (backtype===2){
								return '<a class=\"btn btn-warning btn-xs btn-rounded\" href=\"#\">丢失图书</a>';
							}else if (backtype===3){
								return '<a class=\"btn btn-info btn-xs btn-rounded\" href=\"#\">延迟还书</a>';
							}else {
								return '<a class=\"btn btn-danger btn-xs btn-rounded\" href=\"#\">尚未归还</a>';
							}
							return '<a class=\"btn btn-danger btn-xs btn-rounded\" href=\"#\">尚未归还</a>';
					}
				},
				{
						field: 'exceptRemarks',
						title: '备注'
				}]
		    };
		    $.table.init(options);
		});
	</script>
</body>
</html>